Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

px4io: When running HITL, don't publish actuator_outputs. Fixes #13471. #13488

Merged
merged 1 commit into from
Nov 17, 2019

Conversation

langrind
Copy link
Contributor

See Issue 13471 - vehicle doesn't take off in HITL SIM

The reason it fails:

When running in HITL mode, pwm_out_sim publishes actuator_outputs.

px4io unconditionally publishes the uOrb actuator_outputs. When HITL
is configured, the px4io copy of the uOrb has all zeros.

The result is that there are two publications, one valid, and one
all-zeros. This causes the HIL_ACTUATOR_CONTROLS mavlink message
to be incorrect (all-zeros) and the SERVO_OUTPUTS_RAW mavlink
message to be inconsistent, as it takes the data from one or the
other uOrb randomly each cycle.

The fix is to let px4io know that HITL is in effect when it is
started, and modify px4io to suppress publication in this case.

This is a bigger more complicated fix than I would like, but I
think it is conceptually correct.

An alternative would be to change src/modules/mavlink/mavlink_messages.cpp so that
MavlinkStreamHILActuatorControls() explicitly subscribed to instance 1 of the uOrb:

     _act_sub(_mavlink->add_orb_subscription(ORB_ID(actuator_outputs), 1)), _act_time(0)

That's a one-line solution, but I think it is incorrect because nothing enforces which pub of the uOrb is instance 0 and which is instance 1. And, I just think it doesn't make sense to have two pubs.

Test data / coverage
I simply verified that the failure case in #13471 is fixed. I also verified that the Pixhawk still boots when HITL is not enabled.

Signed-off-by: Nik Langrind [email protected]

…3471.

When running in HITL mode, pwm_out_sim publishes actuator_outputs.

px4io unconditionally publishes the uOrb actuator_outputs. When HITL
is configured, the px4io copy of the uOrb has all zeros.

The result is that there are two publications, one valid, and one
all-zeros. This causes the HIL_ACTUATOR_CONTROLS mavlink message
to be incorrect (all-zeros) and the SERVO_OUTPUTS_RAW mavlink
message to be inconsistent, as it takes the data from one or the
other uOrb randomly each cycle.

The fix is to let px4io know that HITL is in effect when it is
started, and modify px4io to suppress publication in this case.

This is a bigger more complicated fix than I would like, but I
think it is conceptually correct.

Signed-off-by: Nik Langrind <[email protected]>
@dagar
Copy link
Member

dagar commented Nov 16, 2019

Thanks, this is something that's been broken multiple times.

@LorenzMeier
Copy link
Member

@julianoes @dagar Do we want to pull this into 1.10? I'm tending towards it.

@LorenzMeier LorenzMeier merged commit ba5efa5 into PX4:master Nov 17, 2019
rc_handling_disabled = true;

} else if (!strcmp(argv[1], "hil")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be: strcmp(argv[extra_args], "hil"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, thanks, I will fix. Good eye!

@julianoes
Copy link
Contributor

@julianoes @dagar Do we want to pull this into 1.10? I'm tending towards it.

Yes, I'll backport it.

@julianoes
Copy link
Contributor

Yes, I'll backport it.

@bkueng could you please backport it. It's conflicting and I'm not aware of what has been going on here.

@langrind
Copy link
Contributor Author

@bkueng @julianoes - #13531 is a PR of a cherry pick from master into release/1.10 with the conflict resolved. I hope this makes your work easier. But if not, please decline it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants